package com.lantosec.hmrp.modules.monitor.controller;


import com.lantosec.hmrp.core.kit.Result;
import com.lantosec.hmrp.core.mvc.BaseController;
import com.lantosec.hmrp.modules.monitor.entity.CoreIndexEntity;
import com.lantosec.hmrp.modules.monitor.service.IMonitorCoreIndexService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 大屏核心指标监控控制器
 *
 * @author AutoCode
 * @since 2020-05-27
 */
@Api(value = "大屏核心指标监控控制器", tags = "大屏核心指标监控控制器")
@RestController
@RequestMapping("/monitor/coreIndex")
@Log4j2
public class MonitorCoreIndexController extends BaseController {

    @Autowired
    private IMonitorCoreIndexService service;

    @GetMapping("getCoreIndexList")
    @ApiOperation(value = "核心指标监控列表")
    public Result<List<CoreIndexEntity>> getCoreIndexList(
            @ApiParam(value = "月份") @RequestParam(name = "month",required = false) String month,
            @ApiParam(value = "年份") @RequestParam(name = "year",required = false) Integer year
    ) {
        List<CoreIndexEntity> coreIndexList = service.getCoreIndexList(month,year);
        return Result.ok(coreIndexList);
    }

    @GetMapping("getCoreIndexDetails")
    @ApiOperation(value = "各指标最近30天或一年的记录")
    public Result<List<CoreIndexEntity>> getCoreIndexDetails(
            @ApiParam(value = "月份") @RequestParam(name = "month",required = false) String month,
            @ApiParam(value = "年份") @RequestParam(name = "year",required = false) String year,
            @ApiParam(value = "指标名称") @RequestParam(name = "colName") String colName
    ) {
        List<CoreIndexEntity> coreIndexList = service.getCoreIndexDetails(month,year,colName);
        return Result.ok(coreIndexList);
    }
}
